'''
@Author: B.N
@Date: 2018-11-19 16:10:05
@LastEditors: B.N
@LastEditTime: 2018-11-19 16:15:21
@Description: python特训班第一周作业:九九乘法表(8种)
'''

#输出九九乘法表
#for in循环
for m in range(1, 10):
    for n in range(1, m + 1):
        print("{}*{}={:<2}".format(n, m, m * n), end = " ")
    print("\n")

print("=" * 70)

for m in range(9, 0, -1):
    for n in range(1, m + 1):
        print("{}*{}={:<2}".format(n, m, m * n), end = " ")
    print("\n")

print("=" * 70)

for m in range(1, 10):
    for l in range(1, 10 - m):
        print(end = "       ")
    for n in range(m, 0, -1):
        print("{}*{}={:<2}".format(n, m, m * n), end = " ")
    print ("\n")

print("=" * 70)

for m in range(9, 0, -1):
    for l in range(1, 10 - m):
        print(end = "       ")
    for n in range(m, 0, -1):
        print("{}*{}={:<2}".format(n, m, m * n), end = " ")
    print ("\n")

print("=" * 70)

#while 循环
m = 1
while m < 10:
    n = 1
    while n < m + 1:
        print("{}*{}={:<2}".format(n, m, m * n), end = " ")
        n += 1
    print("\n")
    m += 1

print("=" * 70)

m = 9
while m > 0:
    n = 1
    while n < m + 1:
        print("{}*{}={:<2}".format(n, m, m * n), end = " ")
        n += 1
    print("\n")
    m -= 1

print("=" * 70)

m = 1
while m < 10:
    l = 1
    while l < 10 - m:
        print(end = "       ")
        l += 1
    n = m
    while n > 0:
        print("{}*{}={:<2}".format(n, m, m * n), end = " ")
        n -= 1
    print("\n")
    m += 1

print("=" * 70)

m = 9
while m > 0:
    l = 1
    while l < 10 - m:
        print(end = "       ")
        l += 1
    n = m
    while n > 0:
        print("{}*{}={:<2}".format(n, m, m * n), end = " ")
        n -= 1
    print("\n")
    m -= 1
